package javax.core.security.entity;

import java.security.Principal;

/**
 * 记录在session中的对象，标识用户是否登录 <br/>
 * 注：它只记录用户鉴权相关的信息，不会记录用户的个人信息
 */
public class UserPrincipal implements Principal {
    private final Long id;
    private final String userName;
    private final String name;
    private Long lastVisitTimestamp;

    public UserPrincipal(Long id, String userName, String name) {
        this.id = id;
        this.userName = userName;
        this.name = name;
        this.lastVisitTimestamp = System.currentTimeMillis();
    }

    public Long getId() {
        return id;
    }

    public String getUserName() {
        return userName;
    }

    public Long getLastVisitTimestamp() {
        return lastVisitTimestamp;
    }

    public void setLastVisitTimestamp(Long lastVisitTimestamp) {
        this.lastVisitTimestamp = lastVisitTimestamp;
    }

    @Override
    public String getName() {
        return this.name;
    }
}
